package com.pan.admin.module.market.entity.vo;

import com.gitee.apanlh.util.base.CollUtils;
import com.gitee.apanlh.util.base.Empty;
import com.gitee.apanlh.util.base.IteratorUtils;
import com.gitee.apanlh.util.valid.ValidParam;
import com.pan.admin.module.channel.entity.LoanChannel;
import com.pan.admin.module.channel.entity.LoanChannelMarket;
import lombok.Data;

import java.util.List;


/**
 *  响应实体-贷超渠道屏蔽
 *
 *  @author pan
 */
@Data
public class RespMarketChannelFilterVO {

    private static final long serialVersionUID = 1L;

    /** 所有可选择渠道 */
    private List<RespMarketChannelFilter> listOptional;
    /** 所有已选择的列表 */
    private List<RespMarketChannelFilter> listSelected;

    public static List<RespMarketChannelFilter> ofByChannel(List<LoanChannel> list) {
        if (ValidParam.isEmpty(list)) {
            return Empty.list();
        }

        List<RespMarketChannelFilter> listRespFilter = CollUtils.newArrayList();
        IteratorUtils.array(list, t -> {
            RespMarketChannelFilter respMarketChannelFilter = new RespMarketChannelFilter();
            respMarketChannelFilter.setChannelId(t.getId());
            respMarketChannelFilter.setChannelName(t.getName());
            listRespFilter.add(respMarketChannelFilter);
        });
        return listRespFilter;
    }

    public static List<RespMarketChannelFilter> ofByChannelMarket(List<LoanChannelMarket> list) {
        if (ValidParam.isEmpty(list)) {
            return Empty.list();
        }

        List<RespMarketChannelFilter> listRespFilter = CollUtils.newArrayList();
        IteratorUtils.array(list, t -> {
            RespMarketChannelFilter respMarketChannelFilter = new RespMarketChannelFilter();
            respMarketChannelFilter.setChannelId(t.getLoanChannelId());
            respMarketChannelFilter.setChannelName(t.getChannelName());
            listRespFilter.add(respMarketChannelFilter);
        });
        return listRespFilter;
    }
}
